////
////  XSJRecommendedCCell.m
////  XSJ
////
////  Created by yuanyuan he on 2020/5/8.
////  Copyright © 2020 apple. All rights reserved.
////
//
//#import "XSJRecommendedCCell.h"
//#import "YCHRecommendCollectionCell.h"
//
//@interface XSJRecommendedCCell()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout,YCHRecommendCollectionCellDelegate>
//


#import "XSJRecommendedCCell.h"
#import "XSJRecommendedCollectionCell.h"

@interface XSJRecommendedCCell()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property (strong , nonatomic)UICollectionView *collectionView;

@end

@implementation XSJRecommendedCCell

static NSString *const XSJRecommendedCollectionCelllD = @"XSJRecommendedCollectionCelllD";


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setup];
    }
    return self;
}

- (void)setup
{
    self.contentView.backgroundColor = ColorHex(0xffffff);
    
    [self.contentView addSubview:self.collectionView];
    [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.bottom.right.mas_equalTo(self);
    }];
}


#pragma mark - dataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    //return self.listModel2.list.count;
    return 8;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    XSJRecommendedCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:XSJRecommendedCollectionCelllD forIndexPath:indexPath];
//    HotHouseModel* model = [self.listModel2.list objectAtIndex:indexPath.item];
//    cell.model = model;
    
    return cell;
}

//点击事件
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

//@property (strong , nonatomic)UICollectionView *collectionView;
//
//@end
//
//@implementation XSJRecommendedCCell
//
//static NSString *const YCHRecommendCollectionCelllD = @"YCHRecommendCollectionCelllD";
//
//
//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self)
//    {
//        [self setup];
//    }
//    return self;
//}
//
//- (void)setup
//{
//    self.contentView.backgroundColor = ColorHex(0xffffff);
//
//    [self.contentView addSubview:self.collectionView];
//    [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(10);
//        make.top.bottom.right.mas_equalTo(self);
//    }];
//}
//
//
//#pragma mark - dataSource
//
//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
//{
//    return self.listModel2.list.count;
//}
//
//- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    //礼物
//    YCHRecommendCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:YCHRecommendCollectionCelllD forIndexPath:indexPath];
//    HotHouseModel* model = [self.listModel2.list objectAtIndex:indexPath.item];
//    cell.model = model;
//    cell.delegate = self;
//
//    return cell;
//}
//
////点击事件
//- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
//{

//    HotHouseModel* model = [self.listModel2.list objectAtIndex:indexPath.item];
//    //k房
//    if (self.delegate && [self.delegate respondsToSelector:@selector(YCHRecommendCCellDidClickAtModel:)])
//    {
//        [self.delegate YCHRecommendCCellDidClickAtModel:model];
//    }

    
}


//
//}
//
////+关注
//- (void)YCHRecommendCollectionCellDidClick:(HotHouseModel*)model
//{
//    if (self.delegate && [self.delegate respondsToSelector:@selector(YCHRecommendCCellDidClick:)])
//    {
//        [self.delegate YCHRecommendCCellDidClick:model];
//    }
//}
//
//

//-(void)setListModel2:(HotHouseListModel *)listModel2
//{
//    _listModel2 = listModel2;
//
//    [self.collectionView reloadData];
//}



- (UICollectionView *)collectionView {
    if (_collectionView == nil)
    {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        float fw = kScreenWidth/5;
        layout.itemSize = CGSizeMake(fw, kScreenWidth/5+40);
        layout.minimumLineSpacing = 10;
        layout.minimumInteritemSpacing = 10;
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.backgroundColor = ColorHex(0xffffff);
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.showsHorizontalScrollIndicator = NO;
        
        //礼物
        [_collectionView registerClass:[XSJRecommendedCollectionCell class] forCellWithReuseIdentifier:XSJRecommendedCollectionCelllD];
        
        [self addSubview:_collectionView];
    }
    return _collectionView;
}


@end

//
//
//- (UICollectionView *)collectionView {
//    if (_collectionView == nil)
//    {
//        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
//        float fw = kScreenWidth/3;
//        layout.itemSize = CGSizeMake(fw, kScreenWidth/3+40);
//        layout.minimumLineSpacing = 10;
//        layout.minimumInteritemSpacing = 10;
//        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//
//        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
//        _collectionView.backgroundColor = RGBAColorHex(0xffffff,1.0);
//        _collectionView.delegate = self;
//        _collectionView.dataSource = self;
//        _collectionView.showsHorizontalScrollIndicator = NO;
//
//        //礼物
//        [_collectionView registerClass:[YCHRecommendCollectionCell class] forCellWithReuseIdentifier:YCHRecommendCollectionCelllD];
//
//        [self addSubview:_collectionView];
//    }
//    return _collectionView;
//}
//
//@end

